﻿using Core.SimpleTemp.Application.UserApp;
using Core.SimpleTemp.Common.PagingQuery;
using Core.Toolkit.Core;
using Core.Toolkit.Core.Api;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Core.SimpleTemp.Api.Mobile
{
    /// <summary>
    /// 系统用户
    ///</summary>
    [ApiExplorerSettings(GroupName = "Mobile")]//swagger分类标签
    [Route("api/Mobile/[controller]")]//路由说明
    [EnableCors("any")]//跨域规则
    [ApiController]//APi标识Controller
    [Authorize]//验证是否登录
    public class SysUserController : MobileBaseConteroller
    {
        private readonly SysUserAppService _service;
        /// <summary>
        /// /
        /// </summary>
        /// <param name="service"></param>
        public SysUserController(SysUserAppService service)
        {
            _service = service;
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="pagingQueryModel"></param>
        /// <returns></returns>
        [HttpPost("GetList")]

        public async Task<IActionResult> GetList(PagingModel<SysUserDto> pagingQueryModel)
        {
            IPageModel<SysUserDto> result = null;
            result = await _service.GetList(pagingQueryModel);
            PageModelObj retObj = new PageModelObj();
            retObj.PageData = result.PageData?.Select(a => new
            {
                a.Id,
                a.SysUserInfor.Name
            }
            ).ToList();
            retObj.RowCount = result.RowCount;
            return this.JsonSuccess(retObj);
        }
    }
}
